<template>
  <div class="user-introduce">
    <van-nav-bar :style="{backgroundColor: '#f5f5f5'}">
      <div slot="left">
        <van-button size="small" plain type="primary" @click="$emit('close')">取消</van-button>
      </div>
      <div slot="right">
        <van-button size="small"  type="primary" @click="onYesIntroduce">确定</van-button>
      </div>
    </van-nav-bar>


    <van-field
      v-model="introValue"
      rows="2"
      autosize
      label="个人简介"
      type="textarea"
      maxlength="50"
      placeholder="请输入要修改的简介内容"
      show-word-limit
    />
    <div class="introduceTextBox">
      <span class="introduceText">*个人简介</span>
    </div>
  </div>
</template>

<script>
import { patchEditUserProfile } from '@/service/getDate'
export default {
  name: 'userIntroduce',
  data () {
    return {
      introValue: ''
    }
  },
  methods: {
   async onYesIntroduce(){
      try {
           await patchEditUserProfile({
            intro: this.introValue
           })
           this.$emit('input', this.introValue)
           this.$toast.success('修改成功')
      }catch(err) {
        this.$toast.fail('修改失败')
      }
      this.$emit('close')
    }
  }
}
</script>

<style lang="scss" scoped>
   .user-introduce {
    .introduceTextBox {
      line-height: 1;
      .introduceText{
        font-size: 25px;
        color: #999;
        padding-left: 30px;
      }
    }
   }
</style>